import Mock from 'mockjs'
var billTemp = Mock.mock({
    'list|50': [{
        'id|+1': 1,
        'taskTmplName': '单据模板@id',
        'categoryName': '单据分类@id',
        'creatorId': '100@id',
        'creator': '@cname()',
        'createTime': '@date()',
        'categoryCode': '000@id'
    }]
})
export default [

    // 单据模板分页
    {
        url: '/bill/templet/getAllSimpleList',
        type: 'post',
        response: config => {
            let { pageSize = 10, currentPage = 1 } = config.body
            console.log(config.body)
            const total = billTemp.list.length
            let list = billTemp.list.slice(pageSize * (currentPage - 1), currentPage * pageSize)
            return {
                code: 20000,
                data: {
                    list,
                    currentPage,
                    pageSize,
                    totalCount: total,
                    totalPages: (total + pageSize - 1) / pageSize,
                }
            }
        }
    },
    //单据模板删除
    {
        url: '/bill/templet/dropTemplete',
        type: 'post',
        response: config => {
            const { id } = config.body
            if (!id) {
                return {
                    code: 403,
                    msg: '删除失败',
                    data: null
                }
            }
            return {
                code: 20000,
                msg: '处理成功',
                data: id
            }
        }
    },
    //单据模板新增
    {
        url: '/bill/templet/createTemplete',
        type: 'post',
        response: config => {
            const { tmplName } = config.body
            if (!tmplName) {
                return {
                    code: 20203,
                    msg: 'tmplName is require',
                    data: null
                }
            }
            return {
                code: 20000,
                msg: '处理成功',
            }
        }
    },
    //单据模板修改
    {
        url: '/bill/templet/editTemplete',
        type: 'post',
        response: config => {
            const { id, tmplName } = config.body
            if (!tmplName || !id) {
                return {
                    code: 20203,
                    msg: 'id and taskTmplName is require',
                    data: null
                }
            }
            return {
                code: 20000,
                msg: '处理成功',
            }
        }
    },
]